package com.badlogic.androidgames.framework.impl;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;

import android.content.res.AssetManager;
import android.os.Environment;
import android.util.Log;

import com.badlogic.androidgames.framework.FileIO;

public class AndroidFileIO implements FileIO {
	AssetManager manager ;
	String externalStoragePath;
	
	public AndroidFileIO(AssetManager manager) {
		this.manager = manager;
		externalStoragePath = Environment.getExternalStorageDirectory() + File.separator ;
		Log.d("AndroidFileIO",  externalStoragePath);
	}
	
	@Override
	public InputStream readAssets(String filename) throws IOException{
		return manager.open(filename);
	}

	@Override
	public InputStream readFile(String filename)throws IOException{
		return new FileInputStream(externalStoragePath + filename); 
	}
	
	@Override
	public OutputStream writeFile(String filename)throws IOException{
		return new FileOutputStream(externalStoragePath + filename); 
	}
}
